package crp.core.course.domain.repositories;

import com.qwlabs.lang.S2;
import crp.core.course.domain.models.CourseEnrollmentEntity;
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
import io.quarkus.panache.common.Parameters;

import javax.enterprise.context.ApplicationScoped;
import java.util.stream.Stream;

@ApplicationScoped
public class CourseEnrollmentRepository implements PanacheRepositoryBase<CourseEnrollmentEntity, String> {
    public Stream<CourseEnrollmentEntity> findByStudentId(String studentId) {
        if (S2.isEmpty(studentId)) {
            return Stream.empty();
        }
        return find("student.id=:studentId", Parameters.with("studentId", studentId)).stream();
    }
}
